package com.qst.system.service.impl;

import java.util.Collections;
import java.util.List;
import java.util.Map;

import com.qst.system.domain.Loans;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.qst.system.mapper.LoansMapper;
import com.qst.system.domain.vo.LoansVo;
import com.qst.system.service.ILoansService;

/**
 * 贷款Service业务层处理
 * 
 * @author qst
 * @date 2025-08-20
 */
@Service
public class LoansServiceImpl implements ILoansService 
{
    @Autowired
    private LoansMapper loansMapper;

    /**
     * 查询贷款
     * 
     * @param loaId 贷款主键
     * @return 贷款
     */
    @Override
    public LoansVo selectLoansById(Long loaId)
    {
        return loansMapper.selectLoansById(loaId);
    }

    /**
     * 查询贷款列表
     * 
     * @param loansVo 贷款
     * @return 贷款
     */
    @Override
    public List<LoansVo> selectLoansList(LoansVo loansVo)
    {
        return loansMapper.selectLoansList(loansVo);
    }

    /**
     * 新增贷款
     * 
     * @param loansVo 贷款
     * @return 结果
     */
    @Override
    public int insertLoans(LoansVo loansVo)
    {
        return loansMapper.insertLoans(loansVo);
    }

    /**
     * 修改贷款
     * 
     * @param loansVo 贷款
     * @return 结果
     */
    @Override
    public int updateLoans(LoansVo loansVo)
    {
        return loansMapper.updateLoans(loansVo);
    }

    /**
     * 批量删除贷款
     * 
     * @param loaIds 需要删除的贷款主键
     * @return 结果
     */
    @Override
    public int deleteLoansByIds(Long[] loaIds)
    {
        return loansMapper.deleteLoansByIds(loaIds);
    }

    /**
     * 删除贷款信息
     * 
     * @param loaId 贷款主键
     * @return 结果
     */
    @Override
    public int deleteLoansById(Long loaId)
    {
        return loansMapper.deleteLoansById(loaId);
    }

    /**
     * 查询贷款编号列表
     *
     * @return 贷款编号列表
     */
    @Override
    public List<Map<String, Object>> selectLoansNoList() {
        return loansMapper.selectLoansNoList();
    }

    /**
     * 获取银行名称列表
     *
     * @return 银行名称列表
     */
    @Override
    public List<String> getBankNames() {
        return loansMapper.getBankNames();
    }
    
    /**
     * 更新贷款状态
     * 
     * @param loaId 贷款ID
     * @param state 状态值
     * @return 结果
     */
    @Override
    public int updateLoansState(Long loaId, String state) {
        LoansVo loansVo = new LoansVo();
        loansVo.setLoaId(loaId);
        loansVo.setLoaState(state);
        return loansMapper.updateLoans(loansVo);
    }
}